let matter = document.querySelector('main')
console.log(matter);
let id = getQueryString('categoryid')

console.log(id);

let pe = getQueryString('productid')
console.log(pe);
let tt = getQueryString('titleid')

let qqq = document.querySelector(".logo")

let nav = document.querySelector('.nav')
    //http://chst.vip:1234/api/getproductlist?categoryid=` + id
fetch(`http://chst.vip:1234/api/getproduct?categoryid=${id}&productid=${pe}`)
    .then(body => body.json())
    .then(res => {
        console.log(res);
        let data = res.result[0]
        console.log(data);
let html11  = `
<a href="./../index.html"><span>首页></span></span></a>
<a href="bjssDetail.html?categoryid=${id}&titleid=${tt}"><span class="yi"></span></a>
<a href=""><span class="er">${data.productName}</span></a>
`

nav.innerHTML = html11
ttt()



        let html = `
    <div class="up">
            <div class="Img">
                ${data.productImg}
            </div>
            <div class="Name">
            ${data.productName}
            </div>
            <div class="tag">
                    <div>
                        <div class="tag-top">
                        <span>当前最低</span>
                        <span>￥6000</span>
                        </div>
                        <div class="tao-btn">
                        <span>优质评论</span>
                        <span>8266</span>
                        </div>
                    </div>
            </div>
    </div>
    <div class="down">
        ${data.bjShop}
    </div>
    <div class="comment">
            <h4>网友评价</h4>
            <div class="review">
               
            </div>
    </div>
    `

        matter.innerHTML = html


        let review = document.querySelector('.review')

        fetch(`http://chst.vip:1234/api/getproductcom?productid=${pe}`)
            .then(body => body.json())
            .then(res => {
                console.log(res);
                let data = res.result
                console.log(data);
                let el = ''
                data.forEach(item => {
                    el += `
           <div class="each">
           <div class="person">
           <span>${item.comName}</span>
           <span>${item.comTime}</span>
       </div>
       <div class="message">${item.comContent}</div>
       <div class="source">${item.comFrom}</div>
           </div>
            `
                })
                review.innerHTML = el
            })



    })

    

    // 评论地址
    //http://chst.vip:1234/api/getproductcom



    //导航
function ttt(){
    
let yi = document.querySelector('.yi')
console.log(yi);
fetch('http://chst.vip:1234/api/getcategorybyid?categoryid=' + id)
.then(body=>body.json())
.then(res=>{
    console.log(res);
    let data = res.result[0]
    // let i = data.findIndex((value) => value.categoryId == id)

    // console.log(i);
    // console.log(res.result[i]);
    let html2 =`
   <div> ${data.category}></div>
    `

    yi.innerHTML = html2

    html3 = `
    <a href="bjssDetail.html?categoryid=${id}&titleid=${tt}">
    <img src="../assets/imges/logo.png" alt="">
</a>
    `
    qqq.innerHTML = html3

})
}












